package copy;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

// 使用转换流，单个字符读写
public class CopyFileWithConversionStream {
    public static void main(String[] args) {
        try (InputStreamReader isr = new InputStreamReader(new FileInputStream("src/main/source.txt"));
             OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("src/main/destination1.txt"))) {
            int ch;
            while ((ch = isr.read()) != -1) {
                osw.write(ch);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
   